package com.kaibes.core.base.util;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class LocalDateUtils {

    public static LocalDate fromMilliseconds(long milliseconds) {
        return LocalDate.ofEpochDay(milliseconds/1000/60/60/24);
    }
    
    public static String format(LocalDate date, String pattern) {
        return date.format(DateTimeFormatter.ofPattern(pattern));
    }
    
    public static String format(LocalDate date) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        if (date != null) {
            return date.format(formatter);
        } else {
            return "";
        }
    }
}
